﻿using System;
using System.Data.Linq;
using System.Data.Linq.Mapping;
using System.ComponentModel;
using System.Collections.ObjectModel;
using System.Device.Location;

namespace Model
{
    [Table]
    public class Location:ModelBase
    {
        public Location()
        {

        }
        public Location(GeoCoordinate location)
        {
            Latitude = location.Latitude;
            Longitude = location.Longitude;
            Height = location.Altitude;
        }


        private string _id;

        [Column(IsPrimaryKey = true, IsDbGenerated = false,  CanBeNull = false)]
        public string Id
        {
            get { return _id; }
            set { _id = value; }
        }
        private double _latitude;
        /// <summary>
        /// 纬度
        /// </summary>
        [Column]
        public double Latitude
        {
            get { return _latitude; }
            set
            {
                if (!(value == _latitude))
                {
                    NotifyPropertyChanging("Latitude");

                    _latitude = value;
                    NotifyPropertyChanged("Latitude");
                }
            }
        }
        private double _Longitude;
        /// <summary>
        /// 经度
        /// </summary>
        [Column]
        public double Longitude
        {
            get { return _Longitude; }
            set
            {
                if (!(value == _Longitude))
                {
                    NotifyPropertyChanging("Longitude");
                    _Longitude = value;
                    NotifyPropertyChanged("Longitude");
                }
            }
        }

        private double _height;
        [Column]
        public double Height
        {
            get { return _height; }
            set
            {
                if (!(value == _height))
                {
                    NotifyPropertyChanged("Height");
                } _height = value;
            }
        }

        public override string ToString()
        {
            return string.Format("{0},{1}",_latitude,_Longitude);
        }

        
    }
}
